import { getVodCollection, oldIdToNewId } from '@/api/vod'

const Index = () => null

export default Index

export async function getServerSideProps({ params }) {
  const { ep, id } = params

  const res = await getVodCollection(id, {})
  if (res?.data?.id) {
    return {
      redirect: {
        destination: `/vod/play-official/${id}/${ep}`,
        permanent: true
      }
    }
  } else {
    const newRes = await oldIdToNewId(id)
    const cid = newRes?.data?.id
    if (cid) {
      return {
        redirect: {
          destination: `/vod/play-official/${cid}/${ep}`,
          permanent: true
        }
      }
    }
    return { notFound: true }
  }
}
